#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int     N = 0;
int     LEN = 0;
int*    parray = NULL;
int*    warray = NULL;
void process()
{
    int i = 0, j = 0, k = 0, m = 0, n = 0;

    int l = 0, r = 0;

    char* pp = NULL;
    for(i = 0; i < LEN; i++)
    {
        m += parray[i];
    }
    m += LEN;
    pp = (char*)malloc((m+1) * sizeof(char));

    for(i = 0, k = 0; i < LEN; n = parray[i], i++)
    {
        for(j = n; j < parray[i]; j++)
        {
            pp[k++] = '(';
        }
        pp[k++] = ')';
    }
    pp[k] = '\0';

    //
    m = 0;
    for(k = 0; k < strlen(pp); k++)
    {
        while(pp[k] == '(' && k <  strlen(pp))
            k++;
        if(k == strlen(pp))
            break;
        l = 0;
        r = 0;
        for(i = k-1; i >= 0; i--)
        {
            if(pp[i] == '(')
                l++;
            else
                r++;
            if(l - r == 1)
            {
                warray[m++] = r+1;
                break;
            }
        }

    }

    for(i = 0; i < LEN; i++)
    {
        printf("%d ", warray[i]);
    }
    printf("\r\n");

    free(pp);
}

int main()
{
    int i = 0, j = 0;

    //freopen("bin\\debug\\in.txt", "r", stdin);

    scanf("%d", &N);
    for(i = 0; i < N; i++)
    {
        scanf("%d", &LEN);
        parray = (int*)malloc(LEN * sizeof(int));
        warray = (int*)malloc(LEN * sizeof(int));

        for(j = 0; j < LEN; j++)
        {
            scanf("%d", &parray[j]);
        }

        process();

        free(parray);
        free(warray);
    }

    return 0;
}
